package fule.com.playandroidkotlin.ui.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import fule.com.playandroidkotlin.R
import fule.com.playandroidkotlin.ui.model.SearchModel

/**
 *@author: njb
 *@date:   2020/2/7 0007 18:06
 *@desc:
 */
class SearchResultAdapter (data:MutableList<SearchModel.SearcherBean>?) :
        BaseQuickAdapter<SearchModel.SearcherBean,BaseViewHolder>(R.layout.item_article_iv,data) {
    override fun convert(helper: BaseViewHolder, item: SearchModel.SearcherBean) {
        helper.run {
            setText(R.id.tv_username, item.author)

            setText(R.id.tv_content,item.title)
            setText(R.id.tv_time,item.niceDate)
        }
        if(item.chapterName!!.isNotEmpty()){
            helper.setText(R.id.tv_type, item.chapterName)
            helper.getView<TextView>(R.id.tv_type).visibility = View.VISIBLE
        }else{
            helper.getView<TextView>(R.id.tv_type).visibility = View.INVISIBLE
        }
    }
}